package com.xinyi.reactivemvvm.basic.dialog;

import android.content.Context;
import android.view.LayoutInflater;

import androidx.annotation.NonNull;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;

import com.xinyi.basic.base.dialog.BaseDialog;

/**
 * @author 杨耿雷
 * @date 2024/9/25 14:43
 * @description 弹窗ViewBinding基类
 */
public abstract class BaseViewBindingDialog<VDB extends ViewDataBinding> extends BaseDialog {

    public BaseViewBindingDialog(@NonNull Context context, boolean cancelable, @NonNull OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    public BaseViewBindingDialog(@NonNull Context context, int theme) {
        super(context, theme);
    }

    public BaseViewBindingDialog(@NonNull Context context) {
        super(context, com.xinyi.basic.R.style.BaseDialogTheme);
    }

    protected VDB binding;

    @Override
    public void setDialogContentView() {
        binding = DataBindingUtil.inflate(LayoutInflater.from(getContext()), initLayoutId(), null, false);
        setContentView(binding.getRoot());
        initObserveUI();
    }

    /**
     * 初始化UI观察
     */
    protected void initObserveUI() { }
}
